import 'dart:async';
import 'dart:ui';

///验证
class CheckUtils {
  CheckUtils._();

  static final _phone = RegExp(r'1[2-9]\d{9}$');

  ///手机号码验证
  static String phoneCheck(String val) {
    if (val.trim().isEmpty) {
      return "请输入手机号码";
    } else if (!_phone.hasMatch(val)) {
      return "手机号码格式不正确";
    } else {
      return "";
    }
  }

  static Timer? _debounce;

  ///防抖方法
  static void debounce(VoidCallback func, {int delay = 500}) {
    if(_debounce?.isActive??false) _debounce?.cancel();
    _debounce = Timer(Duration(milliseconds: delay), func);
  }
}
